import type { ProColumns } from '@ant-design/pro-table'; //引入表头类型
import { DeliverRulerColumnsItem } from './data'; //引入自定义的表格数据类型
import { getDictType } from '@/services/services';

// 表格每列配置
export const deliverRulerColumnsData: ProColumns<DeliverRulerColumnsItem>[] = [
  // 表格表头和单元格配置
  {
    title: '序号',
    dataIndex: 'index',
    valueType: 'indexBorder',
    hideInSearch: true, // 不在搜索表单中出现
    width: 50,
    fixed: 'left',
  },
  {
    title: '空投名称',
    dataIndex: 'name',
    width: 120,
    fixed: 'left',
    fieldProps: {
      // 输入框配置
      maxLength: 20, // 最大输入长度
    },
  },
  {
    title: '空投编码',
    dataIndex: 'code',
    width: 160,
    fieldProps: {
      // 输入框配置
      maxLength: 20, // 最大输入长度
    },
  },
  {
    title: '空投范围',
    hideInSearch: true,
    width: 180,
    dataIndex: 'airdropRange',
    valueType: 'select',
    request: (a) =>
      getDictType({
        dictType: 'deliver-scope',
        pageSize: 10,
        current: 1,
      }).then((res: any) => {
        let data: any = [];
        res.data.map((item: any, index: number) => {
          data[index] = {
            value: item.itemValue,
            label: item.label,
          };
        });
        return data;
      }),
  },
  {
    title: '投放物',
    width: 100,
    dataIndex: 'type',
    valueType: 'select',
    request: (a) =>
      getDictType({
        dictType: 'deliver-type',
        pageSize: 10,
        current: 1,
      }).then((res: any) => {
        let data: any = [];
        res.data.map((item: any, index: number) => {
          data[index] = {
            value: item.itemValue,
            label: item.label,
          };
        });
        return data;
      }),
  },
  {
    title: '空投数目',
    hideInSearch: true,
    dataIndex: 'amount',
    width: 100,
  },
  {
    title: '空投状态',
    dataIndex: 'status',
    valueType: 'select',
    width: 100,
    valueEnum: {
      1: {
        text: '待空投',
        status: 'Default',
      },
      2: {
        text: '已空投',
        status: 'Success',
      },
    },
  },
  {
    title: '操作',
    dataIndex: 'action',
    hideInSearch: true,
    width: 150,
    fixed: 'right',
  },
];
